#!/usr/bin/env python 
# -*- coding: utf-8 -*-
# @Time    : 2023/5/4 17:54
# @Author  : Junzhao
# @File    : 增001.py
# @Software: PyCharm
import pymysql

while True:
    uname = input("用户名：(输入q/Q退出录入)")
    if uname == "q" or uname == "Q":
        break
    pwd = input("密码：")
    mobile = input("手机号码：")

    # 链接MySQL
    conn = pymysql.connect(host="127.0.0.1", port=3306, user='root', password="", charset='utf8', db='unicom')
    cursor = conn.cursor()

    # 发送指令
    sql = "insert into admin(username,password,mobile) values(%(n1)s,%(n2)s,%(n3)s)"
    cursor.execute(sql, {"n1": uname, "n2": pwd, "n3": mobile})
    conn.commit()

    # 关闭连接
    cursor.close()
    conn.close()
print("已退出")
